<#include "license.ftl">
<@license/>
<#assign enums = doc.enums>
package ${enums.package}.gwt.model.enums;

import redora.client.EnumDisplay;

import ${enums.package}.gwt.constants.GlobalEnumConstants;

/**
<#if enums.enum[0].@description[0]??>
 * ${enums.enum[0].@description} 
</#if>
 * Global enumeration. Can be used by several pojo's.
 * @author Redora (www.redora.net)
*/
public enum ${enums.name} implements EnumDisplay {

<#list doc["//element"] as value>
    <#if value.description[0]??>
    /** ${value.description} */
    </#if>
    ${value.@name}(
            ((GlobalEnumConstants)com.google.gwt.core.client.GWT.create(GlobalEnumConstants.class)).${enums.fieldName}_${value.@name}_table()
            , ((GlobalEnumConstants)com.google.gwt.core.client.GWT.create(GlobalEnumConstants.class)).${enums.fieldName}_${value.@name}_form())<#if value_has_next>,<#else>;</#if>
</#list>

    String displayForm;
    String displayTable;

    ${enums.name}(String table, String form) {
        displayTable = table;
        displayForm = form;
    }

    @Override
    public String displayForm() {
        return displayForm;
    }

    @Override
    public String displayTable() {
        return displayTable;
    }

    /** @return Null, or the result of valueOf() */
    public static ${enums.name} valueOfNullSafe(String value) {
        if (value != null && value.length() > 0) {
            return valueOf(value);
        }
        return null;
    }
}